Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Deque - Array #321

Merged
merged 9 commits into from
Jan 31, 2021
Merged

Added Deque - Array #321

merged 9 commits into from
Jan 31, 2021

Conversation

Arvind-raj06
Copy link
Member

Array Deque

References to other Issues or PRs or Relevant literature

"Fixes #120". See #120

Brief description of what is fixed or changed

Added Array deque with DODA and created a abstract class for Deque

Other comments

Hope this code works fine and if there is any issue ping me, yes this PR also included the SWOC participation

@codecov
Copy link

codecov bot commented Jan 23, 2021

Codecov Report

Merging #321 (b2e588c) into master (09b338c) will decrease coverage by 0.271%.
The diff coverage is 86.764%.

@@              Coverage Diff              @@
##            master      #321       +/-   ##
=============================================
- Coverage   98.828%   98.557%   -0.272%     
=============================================
  Files           25        25               
  Lines         3073      3119       +46     
=============================================
+ Hits          3037      3074       +37     
- Misses          36        45        +9     
Impacted Files Coverage Δ
...datastructs/miscellaneous_data_structures/queue.py 95.982% <86.764%> (-4.018%) ⬇️

Impacted file tree graph

@czgdp1807
Copy link
Member

What's the difference between queue or doubly-ended queue other than the difference in end points for adding or removing elements?

@Arvind-raj06
Copy link
Member Author

It can work like a stack and doubly linked list if used in a way but the queue's cannot

@Arvind-raj06
Copy link
Member Author

I have implemented it only for array and yet to be in linked list....

@czgdp1807
Copy link
Member

In other words, can we make queue doubly ended? Do we need an extra class like, Deque? Can we just simply add methods like, appendleft and popleft to queue class? What will be the disadvantages of adapting such approaches?

@Arvind-raj06
Copy link
Member Author

But as per people's knowledge the queue will always insert at end and remove at front but deque will have insert and delete at both sides, that's the reason they call it double ended queue.

@czgdp1807
Copy link
Member

What about adding an extra argument, double_ended in the constructor of queue? If it is True, only then, appendleft and popright will work, otherwise these both will raise error.

@Arvind-raj06
Copy link
Member Author

Yeah that can work too

@Arvind-raj06
Copy link
Member Author

But I need to reframe the rear pointer to work for both double ended queue and regular queue if that's ok I will proceed doing changes with commit.

@czgdp1807
Copy link
Member

You can try changes with queue. But do not delete ArrayDeque in your work branch for this PR in case we don't go with changes in queue.

@Arvind-raj06
Copy link
Member Author

Cool I will complete it right away and show it you

@Arvind-raj06
Copy link
Member Author

@czgdp1807 Now will this work!?

else:
obj.front = 0
obj.rear = items._num - 1
obj.deque = double_ended
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why different names? obj.double_ended should have worked.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure a thing

@czgdp1807
Copy link
Member

You can remove the Deque class.

@Arvind-raj06
Copy link
Member Author

You can remove the Deque class.

Yes

@Arvind-raj06
Copy link
Member Author

@czgdp1807 Done

@czgdp1807
Copy link
Member

Please make similar changes for LinkedListQueue and remaining implementations of queues.

@Arvind-raj06
Copy link
Member Author

Arvind-raj06 commented Jan 29, 2021

Please make similar changes for LinkedListQueue and remaining implementations of queues.

Yeah sure

@czgdp1807 I have a doubt in implementing the above in priority queue what should I name the operation as but in wikipedia it's given as https://en.wikipedia.org/wiki/Double-ended_priority_queue#Operations

@czgdp1807
Copy link
Member

czgdp1807 commented Jan 29, 2021

PriorityQueue isn' t a queue as far as I remember. The double ended property should only be added to the sub classes of Queue.

@Arvind-raj06
Copy link
Member Author

@czgdp1807 I did some improvements on suffix tree, it's working quite fine and shall I make the PR after this or now!

@czgdp1807 czgdp1807 added the SWoC label Jan 31, 2021
@czgdp1807
Copy link
Member

it's working quite fine and shall I make the PR after this or now!

Sure.

@Arvind-raj06
Copy link
Member Author

it's working quite fine and shall I make the PR after this or now!

Sure.

Yeah

@czgdp1807 czgdp1807 merged commit 250ed6f into codezonediitj:master Jan 31, 2021
@Arvind-raj06 Arvind-raj06 deleted the Codehard branch February 4, 2021 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array implementation of doubly ended queue (deque)
2 participants